class Person {
    constructor(private name:string) {
        console.log("haha")
        this.name = name;
    }
    eat(){
        console.log(this.name)
        console.log("i'm eating")
    }
}
var p1 = new Person("batman");
p1.eat();

var p2 = new Person("superman");
p2.eat();

class Employee extends Person{
    constructor(name:string,code:string){
        super(name);
        this.code = code;
    }
    code: string;
    work(){
        super.eat();
        this.doWork();
    }
    private doWork(){
        console.log("i'm working")
    }
}



var e1 = new Employee("em","123");
e1.work();

//泛型
var workers: Array<Person> = [];
workers[0] = new Person("zhangsan");
workers[1] = new Employee("em","123");
// workers[2] = 2;

interface IPerson{
    name: string;
    age: number;
}

class Person1{
    constructor(public config:IPerson){

    }
}

var person1 = new Person1({
    name:"zhangsan",
    age:18
});


interface Animal{
    eat():void;
}

class Sheep implements Animal{
    eat(): void {
        console.log("i eat grass");
    }
}

class Tiger implements Animal{
    eat(): void {
        console.log("i eat meat");
    }
}


